package com.jdy.haoduoaiteacher.adapter;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jdy.haoduoaiteacher.activity.BaseActivity;
import com.jdy.haoduoaiteacher.model.HotSearchKey;
import com.ycsj.goldmedalnewconcept.R;

import java.util.ArrayList;

@SuppressLint("InflateParams")
public class HotKeyAdapter extends BaseAdapter {

  private BaseActivity mContext;
  private LayoutInflater mInflater;
  private ArrayList<HotSearchKey> mList;

  public HotKeyAdapter(BaseActivity context, ArrayList<HotSearchKey> list) {
    this.mContext = context;
    this.mList = list;
    mInflater = LayoutInflater.from(mContext);
  }

  @Override
  public int getCount() {
    return mList.size();
  }

  @Override
  public Object getItem(int arg0) {
    return mList.get(arg0);
  }

  @Override
  public long getItemId(int arg0) {
    return arg0;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    HotSearchKey key = mList.get(position);
    ViewHolder holder;
    if (convertView == null) {
      holder = new ViewHolder();
      convertView = mInflater.inflate(R.layout.hotitem, null);
      holder.key = (TextView) convertView.findViewById(R.id.key);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    holder.key.setText(key.name);
    return convertView;
  }

  private static class ViewHolder {
    private TextView key;
  }

}
